home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / CAppendiceOfflineService.as < prev    next >
Text File  |  2007-11-08  |  9KB  |  295 lines

  1. class CAppendiceOfflineService extends mx.remoting.Service
  2. {
  3.    function CAppendiceOfflineService(inCallerObj)
  4.    {
  5.       super();
  6.       this.mCallerObject = inCallerObj;
  7.       mPendingCallList = new Array();
  8.       mPendingCallIdCounter = 0;
  9.       this.Init();
  10.    }
  11.    function release()
  12.    {
  13.    }
  14.    function Init()
  15.    {
  16.       _global.DoVociSearchRequest = function()
  17.       {
  18.       };
  19.       _global.DoContributiSearchRequest = function()
  20.       {
  21.       };
  22.       _global.DoProspettiveSearchRequest = function()
  23.       {
  24.       };
  25.       _global.DoGetProspettiveListRequest = function()
  26.       {
  27.       };
  28.       _global.DoGetLemmaRequest = function()
  29.       {
  30.       };
  31.       _global.DoGetContributoRequest = function()
  32.       {
  33.       };
  34.       _global.DoGetProspettivaRequest = function()
  35.       {
  36.       };
  37.       _global.DoLookUpRequest = function()
  38.       {
  39.       };
  40.       _global.DoGetRecords = function()
  41.       {
  42.       };
  43.       _global.DoAppendiceHtmlExport = function()
  44.       {
  45.       };
  46.    }
  47.    function NewPendingCall(inMethod)
  48.    {
  49.       mPendingCallIdCounter += 1;
  50.       var _loc3_ = "APC" + String(mPendingCallIdCounter);
  51.       var _loc4_ = new mx.remoting.PendingCall(this,inMethod);
  52.       var _loc2_ = new Object();
  53.       _loc2_.id = _loc3_;
  54.       _loc2_.pc = _loc4_;
  55.       _loc2_.returnData = new Object();
  56.       mPendingCallList.push(_loc2_);
  57.       return _loc2_;
  58.    }
  59.    function PopPendingCall(inPcId)
  60.    {
  61.       var _loc2_ = null;
  62.       var _loc1_ = 0;
  63.       while(_loc1_ < mPendingCallList.length)
  64.       {
  65.          if(mPendingCallList[_loc1_].id == inPcId)
  66.          {
  67.             _loc2_ = mPendingCallList[_loc1_];
  68.             mPendingCallList.splice(_loc1_,1);
  69.             break;
  70.          }
  71.          _loc1_ = _loc1_ + 1;
  72.       }
  73.       if(_loc2_ == null)
  74.       {
  75.       }
  76.       return _loc2_;
  77.    }
  78.    function DoVociSearch(searchWords, excludeWords, searchParm)
  79.    {
  80.       var _loc3_ = this.NewPendingCall("DoVociSearch");
  81.       this.mCurrentVociRecordset = new CIndiceOfflineRecordSet(this,"");
  82.       _global.DoVociSearchRequest(this,_loc3_.id,this.mCurrentVociRecordset,searchWords,excludeWords,searchParm);
  83.       return _loc3_.pc;
  84.    }
  85.    function DoVociSearchResult(inPendingCallId, inRecordset)
  86.    {
  87.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  88.       if(_loc2_ != null)
  89.       {
  90.          _loc2_.pc.onResult(inRecordset);
  91.       }
  92.    }
  93.    function DoContributiSearch(searchWords, excludeWords, searchParm)
  94.    {
  95.       var _loc3_ = this.NewPendingCall("DoContributiSearch");
  96.       this.mCurrentContributiRecordset = new CIndiceOfflineRecordSet(this,"");
  97.       _global.DoContributiSearchRequest(this,_loc3_.id,this.mCurrentContributiRecordset,searchWords,excludeWords,searchParm);
  98.       return _loc3_.pc;
  99.    }
  100.    function DoContributiSearchResult(inPendingCallId, inRecordset)
  101.    {
  102.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  103.       if(_loc2_ != null)
  104.       {
  105.          _loc2_.pc.onResult(inRecordset);
  106.       }
  107.    }
  108.    function DoProspettiveSearch(searchWords, excludeWords, searchParm)
  109.    {
  110.       var _loc3_ = this.NewPendingCall("DoProspettiveSearch");
  111.       this.mCurrentProspettiveRecordset = new CIndiceOfflineRecordSet(this,"");
  112.       _global.DoProspettiveSearchRequest(this,_loc3_.id,this.mCurrentProspettiveRecordset,searchWords,excludeWords,searchParm);
  113.       return _loc3_.pc;
  114.    }
  115.    function DoProspettiveSearchResult(inPendingCallId, inRecordset)
  116.    {
  117.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  118.       if(_loc2_ != null)
  119.       {
  120.          _loc2_.pc.onResult(inRecordset);
  121.       }
  122.    }
  123.    function DoGetProspettiveList()
  124.    {
  125.       var _loc3_ = this.NewPendingCall("DoGetProspettiveList");
  126.       _loc3_.returnData = new CDirectorLemma(0);
  127.       _global.DoGetProspettiveListRequest(this,_loc3_.id,_loc3_.returnData);
  128.       return _loc3_.pc;
  129.    }
  130.    function DoGetProspettiveListResult(inPendingCallId)
  131.    {
  132.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  133.       if(_loc2_ != null)
  134.       {
  135.          _loc2_.pc.onResult(_loc2_.returnData.prospettive);
  136.       }
  137.    }
  138.    function DoGetLemma(id)
  139.    {
  140.       var _loc3_ = this.NewPendingCall("DoGetLemma");
  141.       _loc3_.returnData = new CDirectorLemma(id);
  142.       _global.DoGetLemmaRequest(this,_loc3_.id,id,_loc3_.returnData);
  143.       return _loc3_.pc;
  144.    }
  145.    function DoGetLemmaResult(inPendingCallId)
  146.    {
  147.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  148.       if(_loc2_ != null)
  149.       {
  150.          _loc2_.pc.onResult(_loc2_.returnData);
  151.          _loc2_.returnData.free();
  152.          delete _loc2_.returnData;
  153.          _loc2_.returnData = null;
  154.       }
  155.    }
  156.    function DoGetContributo(id)
  157.    {
  158.       var _loc3_ = this.NewPendingCall("DoGetContributo");
  159.       _loc3_.returnData = new CDirectorContributo(id);
  160.       _global.DoGetContributoRequest(this,_loc3_.id,id,_loc3_.returnData);
  161.       return _loc3_.pc;
  162.    }
  163.    function DoGetContributoResult(inPendingCallId, inRetdata)
  164.    {
  165.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  166.       if(_loc2_ != null)
  167.       {
  168.          _loc2_.pc.onResult(inRetdata);
  169.       }
  170.    }
  171.    function DoGetProspettiva(id)
  172.    {
  173.       var _loc3_ = this.NewPendingCall("DoGetProspettiva");
  174.       _loc3_.returnData = new CDirectorProspettiva(id);
  175.       _global.DoGetProspettivaRequest(this,_loc3_.id,id,_loc3_.returnData);
  176.       return _loc3_.pc;
  177.    }
  178.    function DoGetProspettivaResult(inPendingCallId)
  179.    {
  180.       var _loc2_ = this.PopPendingCall(inPendingCallId);
  181.       if(_loc2_ != null)
  182.       {
  183.          _loc2_.pc.onResult(_loc2_.returnData);
  184.          false;
  185.       }
  186.    }
  187.    function DoLookUp(inStr)
  188.    {
  189.       var _loc3_ = this.NewPendingCall("DoLookUp");
  190.       _global.DoLookUpRequest(this,_loc3_.id,inStr);
  191.       return _loc3_.pc;
  192.    }
  193.    function DoLookUpResult(inPendingCallId, voci, contributi, prospettive)
  194.    {
  195.       var _loc3_ = this.PopPendingCall(inPendingCallId);
  196.       if(_loc3_ != null)
  197.       {
  198.          var _loc2_ = new Object();
  199.          _loc2_.voci = voci;
  200.          _loc2_.contributi = contributi;
  201.          _loc2_.prospettive = prospettive;
  202.          _loc3_.pc.onResult(_loc2_);
  203.          false;
  204.       }
  205.    }
  206.    function getRecords(inRecordSetID, inFirst, inNumber)
  207.    {
  208.       var _loc3_ = undefined;
  209.       if(inRecordSetID == 1)
  210.       {
  211.          _loc3_ = this.mCurrentVociRecordset;
  212.       }
  213.       else if(inRecordSetID == 2)
  214.       {
  215.          _loc3_ = this.mCurrentContributiRecordset;
  216.       }
  217.       else
  218.       {
  219.          if(inRecordSetID != 3)
  220.          {
  221.             return undefined;
  222.          }
  223.          _loc3_ = this.mCurrentProspettiveRecordset;
  224.       }
  225.       _global.DoGetRecords(_loc3_,inFirst,inNumber);
  226.    }
  227.    function DoHtmlExport(inName, inCss, inHeader, inBody)
  228.    {
  229.       if(inBody.indexOf("</br>") >= 0)
  230.       {
  231.          inBody = inBody.split("</br>").join("");
  232.       }
  233.       var _loc8_ = inBody.indexOf("<img ") >= 0;
  234.       var _loc7_ = new XML();
  235.       var _loc5_ = new Array();
  236.       inBody = inBody.split("<br>").join("<br />");
  237.       inBody = inBody.split("<BR>").join("<br />");
  238.       var _loc6_ = "";
  239.       var _loc3_ = 0;
  240.       while(_loc3_ < inBody.length)
  241.       {
  242.          if(inBody.charCodeAt(_loc3_) >= 128)
  243.          {
  244.             _loc6_ += "&#" + String(inBody.charCodeAt(_loc3_)) + ";";
  245.          }
  246.          else
  247.          {
  248.             _loc6_ += inBody.charAt(_loc3_);
  249.          }
  250.          _loc3_ = _loc3_ + 1;
  251.       }
  252.       inBody = _loc6_;
  253.       _loc7_.parseXML("<body>" + inBody + "</body>");
  254.       if(_loc8_)
  255.       {
  256.          this.GetEmbeddedImages(_loc7_,_loc5_);
  257.       }
  258.       imageStr = "";
  259.       _loc3_ = 0;
  260.       while(_loc3_ < _loc5_.length)
  261.       {
  262.          if(_loc3_ == 0)
  263.          {
  264.             imageStr = _loc5_[_loc3_];
  265.          }
  266.          else
  267.          {
  268.             imageStr += "|" + _loc5_[_loc3_];
  269.          }
  270.          _loc3_ = _loc3_ + 1;
  271.       }
  272.       _global.DoAppendiceHtmlExport(inName,inCss,inHeader,inBody,imageStr);
  273.    }
  274.    function GetEmbeddedImages(node, imageArray)
  275.    {
  276.       if(node.nodeName != null)
  277.       {
  278.          if(node.nodeName == "img")
  279.          {
  280.             var _loc5_ = node.attributes.src;
  281.             imageArray.push(_loc5_);
  282.          }
  283.       }
  284.       var _loc2_ = node.firstChild;
  285.       while(_loc2_ != null)
  286.       {
  287.          this.GetEmbeddedImages(_loc2_,imageArray);
  288.          _loc2_ = _loc2_.nextSibling;
  289.       }
  290.    }
  291.    function onDirectorError(pcId, errNo, errMsg)
  292.    {
  293.    }
  294. }
  295.